package com.example.jucdemo.waitnotify.dmeo2;

/**
 * @Author by KoVaVo
 * @Date 2023-05-20 19:15
 * @Desc: 消费者
 */
public class code03_Consumer {

    private String lock;

    public code03_Consumer(String lock){
        super();
        this.lock = lock;
    }

    public void getValue(){
        try {
            synchronized (lock){
                if ("".equals(code01_ValueObject.value)){
                    lock.wait();
                }
                System.out.println("get 的值是："+code01_ValueObject.value );
                code01_ValueObject.value = "";
                lock.notify();
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
